package com.fxkj.cloud.drms.domain.device.repository;

import com.fxkj.cloud.dbs.common.constants.DeviceStatusEnum;
import lombok.Getter;

/**
 * <p>description: 设备状态统计</p>
 * @author ww
 * @date 2025/4/10 14:37
 */
@Getter
public class DeviceStatusStatistics {
    private DeviceStatusEnum status;
    private Long num;

    public DeviceStatusStatistics(DeviceStatusEnum status, Long num) {
        this.status = status;
        this.num = num;
    }

    public static DeviceStatusStatistics create(Integer status, Long num) {
        DeviceStatusEnum deviceStatusEnum = DeviceStatusEnum.of(status);
        if (null == deviceStatusEnum){
            throw new RuntimeException("非法设备状态");
        }
        return new DeviceStatusStatistics(deviceStatusEnum,num);
    }

    public static DeviceStatusStatistics defaultDeviceStatusStatistics() {
        return new DeviceStatusStatistics(DeviceStatusEnum.OFFLINE,0L);
    }
}
